package com.example.zk.adapter

import android.content.res.ColorStateList
import android.graphics.Color
import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.example.base.entity.CategoryEntity
import com.example.zk.R

class OneAdapter:BaseQuickAdapter<CategoryEntity,BaseViewHolder>(R.layout.item_one) {
    override fun convert(holder: BaseViewHolder, item: CategoryEntity) {
        holder.setText(R.id.one_tv,item.name)
        if(item.id==selectId){
            holder.getView<TextView>(R.id.one_tv).setTextColor(Color.RED)
        }else{
            holder.getView<TextView>(R.id.one_tv).setTextColor(Color.BLACK)
        }
    }
    //选中的变色
    var selectId = 515
    fun setId(id:Int){
        selectId = id
        notifyDataSetChanged()//刷新适配器，不然不起效果
    }
}